<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<%@ page import="com.sjzl.util.MD5Encrypt" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title><s:property value="title"/></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	
	<link href="css/bbs.css" rel="stylesheet" type="text/css"/>
	<link href="css/reply_list.css" rel="stylesheet" type="text/css"/>
	<link href="css/pagination.css" rel="stylesheet" type="text/css"/>
	<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> 
    <link href="css/AeroWindow.css?r=123" rel="stylesheet" type="text/css"/>
	<link rel="stylesheet" href="fckeditor/editor/plugins/insertcode/insertcode.css">
 	<link rel="stylesheet" href="fckeditor/editor/plugins/HighLighter/dp.SyntaxHighlighter/Styles/SyntaxHighlighter.css">
	
	<script type='text/javascript' src='/sjzl/dwr/interface/CheckTextNull.js'></script>
	<script type='text/javascript' src='/sjzl/dwr/engine.js'></script>
	<script type='text/javascript' src='/sjzl/js/util.js'></script>
	  
    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> 
    <script type="text/javascript" src="js/jquery-ui-1.8.1.custom.min.js"></script> 
    <script type="text/javascript" src="js/jquery.easing.1.3.js"></script>         
    <script type="text/javascript" src="js/jquery-AeroWindow.js"></script>
	<style type="text/css">

	</style>
	
	<script type="text/javascript">
	
		function download() {
			if (confirm("您确定下载该附件吗？")) {
				return true;
			} else {
				return false;
			}
		}
	
		function check(word){
			document.getElementById("name1").value=word;				
		}
		function checkInputEdit() {
			var inputEditor=document.getElementById("inputEditor").value;	
			if(inputEditor=="false"){
				art.dialog({
					lock: true,
    				content: '要求输入的内容不能为空！'
				});
				return false;
			}return true;
			
		}
		function checkText() {
			var oEditor=FCKeditorAPI.GetInstance('input_edit');
			var OEditor="&nbsp;"+oEditor.GetXHTML(true);
			CheckTextNull.checkInputEdit(OEditor,function(data){
				document.getElementById("inputEditor").value=data;
			});
		}
		
		function checkReport(){
			if (confirm("您确定要举报该帖子吗？")) {
				return true;
			} else {
				return false;
			}
		}
		
		$(document).ready(function() {
			$('#chick_visitors_window').click(function() {
	          $('#visitors_window').AeroWindow({
	            WindowTitle:          '查看近期访问者',
	            WindowPositionTop:    'center',
	            WindowPositionLeft:   'center',
	            WindowWidth:          350,
	            WindowHeight:         400,
	            WindowAnimationSpeed: 1000,
	            WindowAnimation:      'easeOutElastic',
	            WindowResizable : false,
				WindowDraggable : true,
				WindowMinimize : false,
				WindowMaximize : false,
				WindowClosable : true
	          });
	        })
		});
		
		$(function()
		{
			var img = $(".content_div img");
			for(var i=0;i<img.length;i++)
			{
				if(img[i].width>1000)
				{
					img[i].width=720;
				}
				if(img[i].width>720&&img[i].width<1000)
				{
					img[i].width=600;
				}
			}
			var fileDownList = $("#fileDownList").html();
			if(fileDownList==null)
			{
				$(".fujian").css("display","none");
			}

		})
	</script>
	
  </head>
  
  <body>
    <s:include value="/top.jsp"></s:include>
    
    	<div class="nav_div">
	    	<div style="width: 940px; margin: auto; position: relative;">
	    		<span>
	    		<s:a href="board_list">论坛首页</s:a>
	    			<s:iterator id="navBoard" value="boardNavList">
	    				&raquo; <s:a href="post_list?board_id=%{#navBoard.id}">${ navBoard.name }</s:a> 
	    			</s:iterator>
	    			&raquo; ${ post.name }
	    		</span>
	    	</div>
	    </div>
    
    	<br/><br/>
    	<div class="main_div">
    		<br/>
    			<div class="pagination_div">
    				${ pagination }
    			</div>
    			<br/>
    			<div class="module_div">
    				<div style="width: 100%; height: 30px; background-repeat: repeat-x;">
    					<p style="color: white; font-size: 13px; margin: 5px;">
		    			主题：${ post.name } &nbsp;&nbsp;<a id="chick_visitors_window" style="color: #FC3; cursor: pointer;">查看近期访问者</a>
		    			</p>
		    			<br/>
		    		</div>
		    		
		    		<div class="table_div">
		    			<table>
		    				<tr style="background-color: #FC3; text-align: center;">	
		    					<td style="width: 16%">作者</td>
			    				<td>正文</td>
		    				</tr>
		    				<!-- 原帖 -->
		    				<tr>
		    					<td rowspan="2" valign="top" style="background-color: #bdc2c2;">
		    						<div class="user_info_div">
		    							<strong>昵称：</strong><s:a href="user_selectUser?selectAccount=%{#request.post.user.account}">${ post.user.account }</s:a>
		    							<br/><br/>
		    							<div style="width: 120px; height: 120px;">
		    							<c:if test="${post.user.headImageSrc == null}">
		    								<img src="images/default_user_head_img.png"></img>
		    							</c:if>
		    							<c:if test="${post.user.headImageSrc != null}">
		    								<img id="img" width="120" height="120" src="userUploadFile/${post.user.headImageSrc }"></img>
		    							</c:if>
		    							</div>
		    							<br/>
		    							<span><strong>会员等级</strong>：${ post.user.level }级</span><br/>
		    							<span><strong>会员积分</strong>：${ post.user.integral }</span><br/>
		    							<span><strong>帖子</strong>：${ post.user.postCount }</span><br/>
		    							<span><strong>姓名</strong>：${ post.user.name }</span><br/>
		    							<span><strong>性别</strong>：${ post.user.sex }</span><br/>
		    							<span><strong>来自</strong>：${ post.user.city }</span>
		    						</div>
		    					</td>
		    					<td style="width:84%; overflow:hidden; background-color: #ecefef;"" height="100%" valign="top">
		    						<div style="border-bottom:1px solid; height: 25px;">
										<span style="font-size: 13px;">
										<span style="color: red;">原帖</span>
										发表时间：<fmt:formatDate value="${ post.dateCreated }" pattern="yyyy/MM/dd HH:mm:ss" />
										</span>
									</div>
									<!-- 正文 -->
		    						<div class="content_div">
		    							${ post.content }
									</div>
									<div class="fujian">
											<p style="color:#000;"> 附件 : <span style="color : red">下载附件需要消耗您5点会员积分</span>  </p>
										    <table>
										    	<s:iterator value="uploadFiles">
				    								<tr>
				    									<td>
				    										<a id="fileDownList" href="download.action?name=${uploadRealName }&realname=${uploadFileName }" onclick="return download();">${uploadFileName}</a>
				    									</td>
				    								</tr>
				    							</s:iterator>
				    						</table>
		    					    </div>
		    					</td>
		    				</tr>
		    				<tr class="bottom_tr">
		    					<td style="height: 20px; vertical-align:bottom; background-color: #000; border: 0px;">
				    				<span>
				    					<a href="javascript:scroll(0,0)" title="顶端">返回顶楼</a>
				    					&nbsp;&nbsp;<s:a href="reply_report?post_id=%{#request.post_id}" onclick="return checkReport()">举报</s:a><span style="color: red;"> -- 如果发现其帖子内容中有不健康的元素，可点击举报，由版主负责处理</span>
				    				</span>
				    			</td>
		    				</tr>
		    				
		    				<!-- 回帖 -->
		    				<s:iterator id="reply" value="replyList" status="statu">
		    					<tr><td colspan="2"><hr/><br/></td></tr>
		    					<tr>
			    					<td rowspan="2" valign="top" style="background-color: #bdc2c2;">
			    						<div class="user_info_div">
			    							<strong>昵称：</strong><s:a href="user_selectUser?selectAccount=%{#reply.user.account}">${ reply.user.account }</s:a>
			    							<br/><br/>
			    							<div style="width: 120px; height: 120px;">
			    							<c:if test="${reply.user.headImageSrc == null}">
			    								<img src="images/default_user_head_img.png"></img>
			    							</c:if>
			    							<c:if test="${reply.user.headImageSrc != null}">
			    								<img id="img" width="120" height="120" src="userUploadFile/${reply.user.headImageSrc }"></img>
			    							</c:if>
			    							</div>
			    							<br/>
			    							<span><strong>会员等级</strong>：${ reply.user.level }级</span><br/>
			    							<span><strong>会员积分</strong>：${ reply.user.integral }</span><br/>
			    							<span><strong>帖子</strong>：${ reply.user.postCount }</span><br/>
			    							<span><strong>姓名</strong>：${ reply.user.name }</span><br/>
		    								<span><strong>性别</strong>：${ reply.user.sex }</span><br/>
		    								<span><strong>来自</strong>：${ reply.user.city }</span>
			    						</div>
			    					</td>
			    					<td style="width:84%; overflow:hidden; background-color: #ecefef;"" height="100%" valign="top">
			    						<div style="border-bottom:1px solid; height: 25px;">
											<span style="font-size: 13px;">
												<span style="color: red;">${ reply.floor }楼</span>
												发表时间：<fmt:formatDate value="${ reply.dateCreated }" pattern="yyyy/MM/dd HH:mm:ss" />
												&nbsp;&nbsp;&nbsp;&nbsp;<strong>标题：${ reply.name }</strong>
											</span>
										</div>
										<!-- 正文 -->
			    						<div class="content_div">
			    							${ reply.content }
			    							<!-- 显示回复回帖信息 -->
			    							<s:iterator id="subReply" value="%{#reply.subReply}">
			    								<div class="rReply_div">
			    									<table style="border: 0px;">
			    										<tr>
			    											<td><img src="images/bbs/rReply_icon.png"/></td>
			    											<td style="width: 90%;">
			    												回复者：<s:text name="%{#subReply.user.account}"></s:text>
			    												回复时间：<s:text name="%{#subReply.dateCreated}"></s:text>
			    											</td>
			    										</tr>
			    									</table>
			    									回复内容：<s:text name="%{#subReply.content}"></s:text>
			    								</div>
			    							</s:iterator>
			    							<!-- 显示回复回帖信息 end -->
										</div>
										<!-- 正文  end -->
			    					</td>
			    				</tr>
			    				<tr class="bottom_tr">
			    					<td style="height: 20px; vertical-align:bottom; background-color: #000; border: 0px;">
					    				<span>
					    				<a href="javascript:scroll(0,0)" title="顶端">返回顶楼</a>
					    				&nbsp;&nbsp;<s:a href="reply_createRReplyUI?reply_id=%{#reply.id}&post_id=%{#request.post_id}">回复</s:a>
					    				&nbsp;&nbsp;<s:a href="reply_deleteReply">删除此回帖</s:a>
					    				</span>
					    			</td>
			    				</tr>
		    				</s:iterator>
		    				
		    			</table>
		    			<br/>
		    			<div class="pagination_div">
    						${ pagination }
    					</div>
		    		</div>
		    		
		    		<br/>
		    		<!-- create_reply_div begin -->
		    		<div class="create_reply_div">
		    			<!--  
		    			<div class="create_reply_left_div"></div>
		    			-->
		    			<div class="create_reply_right_div">
		    				 &nbsp;<strong style="font-size: 14px; height: 40px; line-height: 30px;">回复内容:</strong> -- <span style="color: red; font-size: 14px;">注：为了您能顺利上传图片，请不要在编辑器中上传带有中文字符的图片</span>
		    				 <%
							 	boolean isLogin = false;//记录用户登陆状态，默认为false
							    String cookieAccount = null;
								String cookieSsid = null;
								if(request.getCookies() != null){
									for(Cookie cookie : request.getCookies()){
										if(cookie.getName().equals("account"))
											cookieAccount = cookie.getValue();
										if(cookie.getName().equals("ssid"))
											cookieSsid = cookie.getValue();
									}
								}
								if(cookieAccount != null && cookieSsid != null){
									//如果加密规则正确, 则视为已经登录
									if(cookieSsid.equals(MD5Encrypt.calcMD5(cookieAccount + MD5Encrypt.getKey()))){
										isLogin = true;
									}
								}
								HttpSession httpSession = request.getSession();
								Object obj = httpSession.getAttribute("sessionUser");
							    if(!isLogin || obj == null){
							 %>
						     	<span style="font-size:13px;"><a style="color: red; font-size: 14px;">匿名用户不能发表回复！</a> <a href="login.jsp">登录</a></span>
						     <%	} %>	
		    				<form action="reply_create" method="post">
		    					<input type="hidden" name="post_id" value="${ post.id }"/>
		    					&nbsp;<span style="font-size: 13px;">标题：</span><input type="text" size="50" name="reply.name" value="${post.name}"/><span style="color: red; font-size: 13px;">默认使用当前帖子标题，用户可修改</span>
			    				<FCK:editor instanceName="input_edit" inputName="reply.content" basePath="/fckeditor" toolbarSet="One" height="320px;" width="99%">
			    					<jsp:attribute name="value"></jsp:attribute>
			    				</FCK:editor>
			    			<%if(!isLogin){%>
			    				<input type="submit" value="提交回复" style="width: 80px; height: 25px;" disabled="disabled"" />
			    				<a style="color: red; font-size: 14px;">匿名用户不能发表回复！</a>
			    			<%}else{%>
			    				<s:hidden id="inputEditor" value=""></s:hidden>
			    				<s:submit value="提交回复" onmouseover="checkText()" onclick="return checkInputEdit()" cssStyle="width: 80px; height: 30px;"></s:submit>
			    			<%} %>
		    				</form>
		    			</div>
		    		</div>
		    		<!-- create_reply_div end -->
		    		
    			</div>
    		<br/>
    	</div>
    	<!-- 显示来访者的窗口  -->
    	<div id="visitors_window" style="display: none;">
    		<div class="module_div">
    			<div style="width: 100%; height: 30px; background-repeat: repeat-x;">
    				<p style="color: white;">今日访客</p>
    				<br/>
		    	</div>
		    	
		    	<div class="table_div" style="font-size: 13px;">
		    		<br/>
		    		<table>
		    			<s:iterator id="visitor" value="todayVisitors">
		    			<tr>
		    				<td style="width: 45px;">
		    					<c:if test="${visitor.headImageSrc == null || visitor.headImageSrc == ''}">
				    				<img src="images/default_user_head_img.png" width="40" height="40"></img>
				    			</c:if>
				    			<c:if test="${visitor.headImageSrc != null}">
				    				<img id="img" width="40" height="40" src="userUploadFile/${visitor.headImageSrc }"></img>
				    			</c:if>
		    				</td>
		    				<td>
		    					<span>访问者：${ visitor.vusername }</span><br/>
		    					<span>访问时间：<fmt:formatDate value="${ visitor.dateCreated }" pattern="yyyy/MM/dd HH:mm:ss" /></span>
		    				</td>
		    			</tr>
		    			<tr>
		    				<td colspan="2"><hr/></td>
		    			</tr>
		    			</s:iterator>
		    		</table>
		    		<br/>
		    	</div>
    		</div>
    	</div>
    	<!-- 显示来访者的窗口 end -->
    	${ warning }
    
    <s:include value="/bottom.jsp"></s:include>
  </body>
</html>
